
Ccay.Module.define("Ccay.example.ui.permissionControl",function(page,$S){
	
	page.ready=function(){			
		$("#permissionControlDemo").ccayTab();		
		
		var gridParam1 = {
				height: 150,
			    columns: [
			        {columnType:"operate",content:"${#userOp()}",width:100},
			 		{field: 'name', width:70, header: "string"},
			 		{field: 'sex', width:50, header: "bool", type: 'bool', format:{htmlView: true}},
			 		{field: 'age', width:60, header: "integer", type: 'integer'},
			 		{field: 'tuition', width:70, header: "number", type: 'number', format:{fraction: 2}},
			 		{field: 'tuition', width:70, header: "currency", type: 'currency', format:{fraction: 2, flag: '￥[currency]'}},
			 		{field: 'tuition', width:90, header: "rate", type: 'rate', format: {total: 1  , fraction: 1, htmlView: true, section: [20, 50, 60]}},
			 		{field: 'lastUpdateDate', width:130, header: "datetime", type: 'datetime', format: {renderFormat: 'MM/dd/yyyy hh:mm'}},
			 		{field: 'blog', width:150, header: "ellipsis", renderer: 'ellipsis', format: {len: 20}}
			    ],
				ajax:{
				   	url: 'services/ccay/demo/student/list/page/${pageSize}/${curPage}/${orderBy}'
				}
		};
		$("#igridDemo1").igrid(gridParam1);
	};
	
	/**
	 * 操作
	 */
	userOp=function(record) {
		var str = new Array();
		if (Ccay.Permission.check("Service$UserPermission$read")) {
			str.push("<a class='ccay-icon key'></a>");
		}else{
			str.push("<span style='margin-left:16px'></span>");
		}
		if(Ccay.Permission.check("Service$UserPermission$view")){
						str.push("<a class='ccay-icon view' ></a>");
		}else{
			str.push("<span style='margin-left:16px'></span>");
		}
		if (Ccay.Permission.check("Service$User$update") && Ccay.Permission.check("Service$User$create")) {
			str.push("<a class='ccay-icon edit'  title='"+$i18n("ccay.security.user.edit")+"'></a>");
		}else if(Ccay.Permission.check("Service$User$updateUserAccount")){
			str.push("<a class='ccay-icon reset'></a>");

		}else{
			str.push("<span style='margin-left:16px'></span>");
		}
		return str.join("");
	};
	

});



